/*
 * Ctimer.h
 *
 *  Created on: Jan 21, 2011
 *      Author: alki
 */

#ifndef CTIMER_H_
#define CTIMER_H_

#include <sys/time.h>
#include <math.h>

/**
 * Klasse Ctimer: stoppt die Zeit
 */
class Ctimer {
public:
	Ctimer();
	virtual ~Ctimer();

	void start() {
		m_start = getTickCount();
	}

	long stop() {
		long time = getTickCount() - m_start;
		return time;
	}

private:
	long m_start;

	long getTickCount() {
		struct timeval tv;
	    gettimeofday(&tv,0);
	    return (long)(tv.tv_sec*1000 + (tv.tv_usec/1000));
	}
};

#endif /* CTIMER_H_ */
